

const {ccclass, property} = cc._decorator;

@ccclass
export default class BtnVCodeSend extends cc.Component {
    @property(cc.Node)
    vCodeGray:cc.Node = null;

    @property(cc.Node)
    vCodeNormal:cc.Node = null;

    @property(cc.Label)
    lbDaoJiShi:cc.Label = null;

    _canSendVCode = true;

    _daojishi = 0;
    start () {

    }

    onEnable(){
        this.node.stopAllActions();
        this._canSendVCode = true;
        this.initUI();
    }

    initUI(){

        this.vCodeNormal.active = this._canSendVCode;
        this.vCodeGray.active = !this._canSendVCode;

        if( this._daojishi >= 0){
            this.lbDaoJiShi.string = `${Math.ceil(this._daojishi)}`
        }else {
            this.lbDaoJiShi.string = "";
        }

    }

    sendSucessCallBack(){
        this._daojishi = 60;
        this._canSendVCode = false;
    }

    update(dt){

        this._daojishi -= dt;
        this.initUI();
        if(this._daojishi < 0){
            this._canSendVCode = true;
        }
    }


}
